<div class="cpanel-board-management" ng-app="boardManagementApp" ng-controller="boardManagementController">
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" ng-disabled="!bulk_actions_enabled()"
            data-toggle="dropdown" aria-expanded="false">
      Bulk actions <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu">
      <li><a href="#" data-toggle="modal" data-target="#cpanelBoardModalRemoval">Remove selected</a></li>
    </ul>
  </div>

  <button type="button" class="btn btn-default" data-toggle="modal" data-target="#user-board-form">Create board</button>

  <div class="table-responsive">
    <table class="table table-striped tb-board-management">
      <thead>
      <tr>
        <th><input type="checkbox" class="checkbox-all" /></th>
        <th>Board name</th>
        <th>Category</th>
        <th>Total links</th>
        <th colspan="2">Actions</th>
      <tr>
      </thead>
      <tbody class="cpanel-board-management-list">
        <tr dir-paginate="board in boards | itemsPerPage: boards_per_page" total-items="boards_count">
          <td><input type="checkbox" value="{{ board.tid }}" class="checkbox-board" /></td>
          <td><a href="{{ board.url }}">{{ board.name }}</a></td>
          <td>{{ category_options[board.field_category.und[0].value] }}</td>
          <td>{{ board.links_count }}</td>
          <td class="action">
            <a href="#" ng-click="update_board(board)" data-toggle="modal" data-target="#user-board-form">
              <?php print CommonHelper::crabii_icon('pencil') ?></td>
            </a>
          <td class="action">
            <a href="#" ng-click="delete_board(board)" data-toggle="modal" data-target="#cpanelBoardModalRemoval">
              <?php print CommonHelper::crabii_icon('trash-o') ?>
            </a>
          </td>
        </tr>
      </tbody>
    </table>

    <dir-pagination-controls
      on-page-change="page_changed(newPageNumber)"
      template-url="<?php print '/sites/all/libraries/bower_components/angular-utils-pagination' ?>/dirPagination.tpl.html">
    </dir-pagination-controls>
  </div>

  <?php print theme('user_board_form') ?>

  <div class="modal fade" id="cpanelBoardModalRemoval" tabindex="-1" role="dialog" aria-labelledby="cpanelBoardModalRemovalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <h4 class="modal-title" id="cpanelLinkModalRemovalLabel">Confirm board removal</h4>
        </div>
        <div class="modal-body">
          <p>Are you sure you want to remove following board(s):</p>
          <p>
          <ul>
            <li ng-repeat="board in boards_selected">{{ board.name }}</li>
          </ul>
          </p>
        </div>
        <div class="modal-footer clearfix">
          <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary pull-right" ng-click="delete_boards()">Remove</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
</div>
